#include<iostream>
using namespace std;
#include<vector>
int main(){
    int n, q;
    vector<int> arr(5000010);
    auto s = arr;
    cin >> n >> q;
    for (int i = 1; i <= n;i++){
        scanf("%d", &arr[i]);
    }
    for (int i = 1; i <= n;i++){
        s[i] = arr[i] - arr[i - 1];
    }
    while(q--){
        int l, r, c;
        scanf("%d%d%d", &l, &r, &c);
        s[l] += c;
        s[r + 1] -= c;
    }
    int num = 102;
    for (int i = 1; i <= n; i++)
    {
        s[i] += s[i - 1];
        if(s[i]<num){
            num = s[i];
        }
    }
    cout << num;
}
